// bpm sender

// patch
adc => Gain g  => OnePole p => blackhole;
// square the input
adc => g;
// multiply
3 => g.op;

//300 => f.freq;
//0.5 => f.Q;


// set pole position
0.9 => p.pole;

// listen too?
//p => dac;

// send object
OscSend xmit;
OscSend xmit2;


// aim the transmitter
xmit.setHost( "192.168.178.29", 9999 );
xmit2.setHost( "localhost", 9999 );

0=>int i;

// loop on
while( true ) {
    // <<< p.last() >>>;
    if( p.last() > 0.15 ){
    	i+1=>i;
        <<<i,  "BANG!!">>>;
        xmit.startMsg("/bpm/beat", "i");
        1 => xmit.addInt;
        xmit2.startMsg("/bpm/beat", "i");
        1 => xmit2.addInt;
    }
    0.05::second => now;
}
